One long line
statement option1 option2 option3 option4;
versus several short lines.
statement
option1
option2
option3
option4;
* 5507-02-simon-continuous-variables.sas
author: Steve Simon
date: created 2021-05-30
purpose: to work with continuous variables
license: public domain;
* datasets created in this program
body, original data
body1, row with ht=29.5 removed
body2, ht=29.5 converted to missing
body3, ht_cm calculated;
filename rawdata
"../data/fat.txt";
libname module02
"../data";
ods pdf file=
"../results/5507-02-simon-demo.pdf";
data module02.body;
infile rawdata;
input
case
fat_brozek
fat_siri
dens
age
wt
ht
bmi
ffw
neck
chest
abdomen
hip
thigh
knee
ankle
biceps
forearm
wrist;
label
case="Case number"
fat_brozek="Fat (Brozek's equation)"
fat_siri="Fat (Siri's equation)"
dens="Density"
age="Age (yrs)"
wt="Weight (lbs)"
ht="Height (inches)"
bmi="Body mass index (kg/m^2)"
ffw="Fat Free Weight (lbs)"
neck="Neck circumference (cm)"
chest="Chest circumference (cm)"
abdomen="Abdomen circumference (cm)"
hip="Hip circumference (cm)"
thigh="Thigh circumference (cm)"
knee="Knee circumference (cm)"
ankle="Ankle circumference (cm)"
biceps="Biceps circumference (cm)"
forearm="Forearm circumference (cm)"
wrist="Wrist circumference (cm)";
run;
* Some additional details about this data:
Brozek's equation is 457/Density - 414.2
Siri's equation is 495/Density - 450
Abdomen circumference is measured at the
umbilicus and level with the iliac crest
Wrist circumference is distal to the
styloid processes;
proc print
data=module02.body(obs=10);
var case fat_brozek fat_siri dens age;
title1 "Ten rows and five columns";
title2 "of the body data set";
footnote1 "Created by Steve Simon on &sysdate using SAS &sysver";
run;
proc contents
data=module02.body;
title1 "Internal description of body dataset";
run;
proc means
n mean std min max
data=module02.body;
var ht;
title1 "Descriptive statistics for ht";
title2 "The mean is normal for adults";
title3 "The standard deviation shows tightly packed data";
title4 "The maximum value is reasonable";
title2 "The minimum is very low";
run;
proc sort
data=module02.body;
by ht;
run;
proc print
data=module02.body(obs=1);
title1 "The row with the smallest ht";
title2 "Note the inconsistency with wt";
run;
proc sort
data=module02.body;
by descending ht;
run;
proc print
data=module02.body(obs=1);
title1 "The row with the largest ht";
title2 "This seems quite normal to me";
run;
data module02.body1;
set module02.body;
if ht = 29.5 then delete;
run;
data module02.body2;
set module02.body;
if ht=29.5 then ht=.;
run;
proc print
data=module02.body2;
where ht < 0;
title1 "Printing negative values for ht (wrong way)";
title2 "Use where ht ^= . & ht < 0 instead";
run;
proc means
n nmiss mean std min max
data=module02.body2;
var ht;
title1 "There is one missing value";
run;
data name1;
set name1;
wt_kg = wt / 2.2;
run;
data name2;
set name1;
wt = wt / 2.2;
run;
data module02.body3;
set module02.body2;
ht_m = ht / 39.37;
wt_kg = wt / 2.2;
check_bmi = wt_kg / ht_m**2;
run;
proc print
data=module02.body3(obs=10);
var ht ht_m wt wt_kg bmi check_bmi;
title1 "Original and converted units";
run;
Box drawing characters
░ ▒ ▓ │ ┤ ╡ ╢ ╖ ╕ ╣ ║ ╗ ╝ ╜ ╛ ┐
└ ┴ ┬ ├ ─ ┼ ╞ ╟ ╚ ╔ ╩ ╦ ╠ ═ ╬ ╧
╨ ╤ ╥ ╙ ╘ ╒ ╓ ╫ ╪ ┘ ┌ █ ▄ ▌ ▐ ▀
Before box drawing characters
| - +
proc sgplot
data=module02.body3;
histogram ht;
title1 "Histogram with default bins";
run;
proc sgplot
data=module02.body3;
histogram ht / binstart=60 binwidth=1;
title "Histogram with narrow bins";
run;
proc sgplot
data=module02.body3;
histogram ht / binstart=60 binwidth=5;
title "Histogram with wide bins";
run;
proc corr
data=module02.body3
noprint
outp=correlations;
var fat_brozek fat_siri;
with neck -- wrist;
run;
data correlations;
set correlations;
if _type_="CORR";
drop _type_;
fat_brozek=round(fat_brozek, 0.01);
fat_siri=round(fat_siri, 0.01);
run;
proc sort
data=correlations;
by descending fat_brozek;
run;
proc print
data=correlations;
title1 "Abdomen, hip, and chest show the strongest correlations";
run;
proc sgplot
data=module02.body3;
scatter x=abdomen y=fat_brozek;
pbspline x=abdomen y=fat_brozek;
title1 "Simple scatterplot shows a strong positive trend";
title2 "It levels off for high values.";
title3 "This may be due solely to a single outlier on the high end";
run;
ods pdf close;